package xuegao.study.mall.web.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xuegao.study.mall.web.domain.HomeContentResult;
import xuegao.study.mall.web.service.HomeService;
import xuegao.study.mall.common.api.CommonResult;
import xuegao.study.mall.common.model.pms.PmsProductCategory;

import java.util.List;

@RestController
@RequestMapping("/home")
public class HomeController {

    @Autowired
    private HomeService homeService;

    @GetMapping("/content")
    public CommonResult<HomeContentResult> content() {
        HomeContentResult content = homeService.content();
        return CommonResult.success(content);
    }

    @ApiOperation("获取首页商品分类")
    @GetMapping("/productCateList/{parentId}")
    public CommonResult getProductCateList(@PathVariable Long parentId) {
        List<PmsProductCategory> productCateList = homeService.getProductCateList(parentId);
        return CommonResult.success(productCateList);
    }
}
